home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 October / MACPOWER-1997-10.ISO.7z / MACPOWER-1997-10.ISO / AMUG / INTERNET / HTML Grinder 3.21.sit / HTML Grinder / Grinder Tools / Insert Image Size Tags / background_3885.xml next >
Extensible Markup Language  |  1997-07-01  |  5KB  |  44 lines

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE background PUBLIC "-//Apple, Inc.//DTD background V 2.0//EN" "" >
  3. <background>
  4.     <id>3885</id>
  5.     <filler1>0</filler1>
  6.     <cantDelete> <false /> </cantDelete>
  7.     <showPict> <true /> </showPict>
  8.     <dontSearch> <false /> </dontSearch>
  9.     <link rel="stylesheet" type="text/css" href="stylesheet_3279.css" />
  10.     <part>
  11.         <id>5</id>
  12.         <type>button</type>
  13.         <visible> <true /> </visible>
  14.         <reserved5> 0 </reserved5>
  15.         <reserved4> 0 </reserved4>
  16.         <reserved3> 0 </reserved3>
  17.         <reserved2> 0 </reserved2>
  18.         <reserved1> 0 </reserved1>
  19.         <enabled> <true /> </enabled>
  20.         <rect>
  21.             <left>0</left>
  22.             <top>127</top>
  23.             <right>17</right>
  24.             <bottom>144</bottom>
  25.         </rect>
  26.         <style>opaque</style>
  27.         <showName> <false /> </showName>
  28.         <highlight> <false /> </highlight>
  29.         <autoHighlight> <true /> </autoHighlight>
  30.         <sharedHighlight> <true /> </sharedHighlight>
  31.         <family>0</family>
  32.         <titleWidth>0</titleWidth>
  33.         <icon>29540</icon>
  34.         <textAlign>center</textAlign>
  35.         <font>Chicago</font>
  36.         <textSize>12</textSize>
  37.         <textStyle>plain</textStyle>
  38.         <name>Help</name>
  39.         <script>on mouseUpfullhelpend mouseUpon mouseenterhelper "Click here for more help for HTML Grinder."end mouseenter</script>
  40.     </part>
  41.     <name></name>
  42.     <script>function applescriptcapableput systemfolder() & "extensions:scripting additions:Read/Write Commands" into thefileif there is no file thefile or there is no scriptinglanguage "AppleScript"then return falseelse return trueend applescriptcapableon openstackif not applescriptcapable()then put "Standard" into cd fld popperpass openstackend openstackon enterkeyclick at the loc of cd btn id 8end enterkeyon converter thefile,thecontentsglobal totalchangesput inlinedimages(thefile,thecontents) into allimagesrepeat with x = the number of lines in allimages down to 1set cursor to busyget line x of allimagesif item 2 of it is not "OK" then next repeatput item 4 of it into theimage-- put item 5 of it into theHTMLcodeput item 6 of it into thestartput item 7 of it into theEndput char thestart to theend of thecontents into theHTMLCodeput addSizes(theimage,theHTMLcode) into newHTMLcodeif "ERROR:" is not in newHTMLcode thenadd 1 to totalchangesput newHTMLcode into char thestart to theend of thecontentsend ifend repeatreplacefile thefile,thecontentsend converteron alldoneglobal totalchangesget "Size parameters were added to" && totalchanges && "image tags."put "0" into totalchangessend "alldone it" to homie()end alldonefunction addSizes theimage,theHTMLcodeif there is no file theimage then return "ERROR: image file not found"if theHTMLcode contains "width" or theHTMLcode contains "height"then return "ERROR: already has size tags"--put giffer(theimage) into thedimsif item 1 of thedims is a numberthen put " width=" & item 1 of thedims into thewidthelse put empty into thewidthif char 1 of item 2 of thedims is " "then delete char 1 of item 2 of thedimsif item 2 of thedims is a numberthen put " height=" & item 2 of thedims into theheightelse put empty into theheight--put thewidth & theheight after char 4 of theHTMLcodereturn theHTMLcodeend addSizesfunction giffer theimageif cd fld popper is "standard"then return gifdim(theimage)else return hypergifdim(theimage)end giffer-- The HyperGIFDim function employs the "Read/Write Commands" scripting addition-- from Apple (which must be in the Scripting Additions folder) and AppleScript.-- The scripting addition is normally installed with AppleScript version 1.1.-- Also the Finder must be available, which is normally the case.-- An alternative would be to use XFCNs or XCMDs which can read all binary values-- (i.e., as unsigned integer values, or hex) from files.-- Note that the HyperCard read function cannot be used since HyperCard translates-- a null (zero) to a space (ASCII 32).function HyperGIFDim filepathdo ツャ"tell application" && quote & "Finder" & quote & return ツャ& "with transaction" & return ツャ& "copy open for access alias" && quote & filepath & quote && "to FRef" & return ツャ& "read FRef for 6" & return ツャ& "read FRef as data for 4" & return ツャ& "end transaction" & return ツャ& "end tell" & return ツャas AppleScriptput the result into rawdatareturn hexToInt(char 11 to 14 of rawdata) & "," & hexToInt(char 15 to 18 of rawdata)end HyperGIFDimfunction hexToInt data  -- Convert two hex bytes into an unsigned short integer.put 0 into myIntrepeat with i = 1 to 4multiply myInt by 16add offset(char (char i of "3412") of data,"123456789ABCDEF") to myIntend repeatreturn myIntend hexToInton resetwheelput "Standard" into cd fld popperpass resetwheelend resetwheel</script>
  43. </background>
  44.